import SearchHeader from "./SearchHeader";
import SimpleSearch from "./SimpleSearch";
import HighLevelSearch from "./HighLevelSearch";
import NavView from "./NavView";
import LoginHeader from "./LoginHeader";
import logo from "../../../../imgs/logo.png";
import HttpUtils from "../utils/HttpUtils";
import "../css/commheader.css";

import SimpleHeader from "@page/common/comps/SimpleHeader";
import HelpMenu from "@root/P/modules/Help/HelpMenu";
import Uts from "@module/Uts";

export default function CommonHeader(props) {
    const [hignOpen, setHignOpen] = React.useState(false);
    const {
        navOpen,
        isInSupp,
        isInCart,
        searchTab,
        hideHeader,
        isSimpleHeader,
        helpCenter,
        hideClassify,
        isInBid
    } = props;
    if (isSimpleHeader) {
        return (
            <div>
                <SimpleHeader type={isSimpleHeader} />
            </div>
        );
    }

    if (hideHeader) {
        return null;
    }

    if(helpCenter=="1"||helpCenter=="2"||helpCenter=="3"){
        return(
            <div>
                <LoginHeader />
                <div
                    className="app-content-warpper"
                >
                    <div
                        className="search-header-box"
                        style={{height:100}}
                    >
                        <div
                            style={{
                                height: 100,
                                backgroundColor: "#fff",
                                position: "relative",
                                width: "1200px",
                                marginLeft: "auto",
                                marginRight: "auto"
                            }}
                        >
                            <div
                                onClick={() => {
                                    $state.go({
                                        stateName: "/"
                                    });
                                }}
                                style={{
                                    width: 600,
                                    height: 47,
                                    marginTop: 30,
                                    cursor: "pointer",
                                    display:"inline-block"
                                }}
                            >
                                <img className="zen_v-t" src={logo} />
                                <div className="zen_il-bl zen_fs-27 zen_h-45 zen_l-h-45 zen_m-l-20 zen_p-l-20 zen_bold" style={{borderLeft:"2px solid #ccc"}}>{Uts.getCookie("orgId")==""?"帮助中心":"科研单位帮助中心"}</div>
                            </div>
                            <div className="zen_f-right zen_h-40 zen_m-t-30 zen_m-l-30 zen_il-bl">
                                <SimpleSearch
                                    holder = {"请输入关键字"}
                                    searchurl = {""}
                                ></SimpleSearch>
                            </div>
                        </div>
                    </div>
                </div>
                <HelpMenu></HelpMenu>
            </div>
        );
    }

    if (isInCart) {
        return (
            <div>
                <LoginHeader />
                <SearchHeader
                    isInCart={isInCart}
                    showHighLevel={hignOpen}
                    clickHighLevel={() => setHignOpen(true)}
                    hideHighLevel={() => setHignOpen(false)}
                />
                {global.hasLogin && hignOpen && (
                    <HighLevelSearch
                        closeHighSearch={() => setHignOpen(false)}
                    />
                )}
            </div>
        );
    }

    if (isInSupp) {
        return (
            <div>
                <LoginHeader />
                <SearchHeader
                    isInSupp={isInSupp}
                    showHighLevel={hignOpen}
                    clickHighLevel={() => setHignOpen(true)}
                    hideHighLevel={() => setHignOpen(false)}
                />
            </div>
        );
    }

    return (
        <div>
            <LoginHeader />
            <SearchHeader
                searchTab={searchTab}
                showHighLevel={hignOpen}
                clickHighLevel={() => setHignOpen(true)}
                hideHighLevel={() => setHignOpen(false)}
            />
            {hignOpen && (
                <HighLevelSearch closeHighSearch={() => setHignOpen(false)} />
            )}
            <NavView navOpen={navOpen} hideClassify={hideClassify} isInBid={isInBid}/>
        </div>
    );
}
